<?php echo $this->Form->create('SalesDrug'); ?>
<article class="module width_full">
	<header><h3><?php echo __('Add Sales Drug'); ?></h3></header>
	<div class="module_content">
	<?php
		echo '<fieldset>';
	?>
			<label>Data</label>
			<input type="date" required="true" name="data[SalesDrug][date]" />
			<?php 
			echo '</fieldset>';
		echo '<fieldset>';
		echo $this->Form->input('user_id', array('div' => false, 'required'=> true));
		echo '</fieldset>';
	?>
	<h1><?php echo __('Drugs') ?></h1>
	<fieldset>
		<?php echo $this->Form->select('drugs', $drugs, array('div' => false, 'required'=> true)); ?>
		<button id="add" >+</button>
	</fieldset>
	<div class="clear"></div>
	</div>
	<footer>
		<div class="submit_link">
			<input type="submit" value="salvar" />
		</div>
	</footer>
</article><!-- end of post new article -->

<article class="module width_full">
	<header><h3 class="tabs_involved"><?php echo __('Drugs'); ?></h3></header>
	<table class="tablesorter" cellspacing="0"> 
		<thead> 
		<tr>
			<th><?php echo __('Name'); ?></th>
			<th><?php echo __('Quantity'); ?></th>
			<th><?php echo __('Price'); ?></th>
			<th class="actions"><?php echo __('Actions'); ?></th>
		</tr>
		</thead> 
		<tbody id="drug"> 
		</tbody> 
	</table>

</article>

<div id="teste"></div>
</form>
<?php $this->Js->get('#add');
	echo $this->Js->event('click', $this->Js->request(
			array('action' => 'getDrug', 'controller' => 'Drugs'),
			array(
                'async' => true,
                'method' => 'post',
                'dataExpression' => true,
                'data' => $this->Js->serializeForm(array('isForm' => false, 'inline' => true)),
                'evalScripts' => true,
                'success' => '$("#drug").append(data)',
                'type' => 'html'
                )
		));

	$this->Js->get('.item');
	echo $this->Js->event('click', '$(this).parent().parent().remove()');

	echo $this->Js->writeBuffer();